package com.atguigu.edu2021.mock.config;


import com.atguigu.gmall2020.mock.util.ParamUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Configuration
public class AppConfig {


    //public static Date date=new Date();
    public static Long user_session_count = 1000L;

    public static String mock_clear_user = "0";

    public static String mock_clear_busi = "0";

    public static String if_init_paper = "1";

    public static Integer mock_init_paper_max_q = 20;

    public static Integer mock_new_user = 0;

    public static Integer mock_user_update_rate=15;

    public static String mock_date_str = "";

    public static Date mock_date = new Date();

    public static Integer mock_count = 1000;

    public static String mock_type = "log";

    public static String mock_url = "http://localhost:80";

    public static Integer max_mid = 500;

    public static Integer max_uid = 500;

    public static Integer max_coupon_id = 3;

    public static Integer max_course_id = 10;


    public static Integer page_during_max_ms = 20000;


    public static Integer error_rate = 3;

    public static Integer if_realtime = 0;

    public static Integer[] start_time_weight;

    public static Integer[] payment_type_weight;

    public static Integer video_heart_interval_sec = 30;

    public static Integer if_study = 50;

    public static Integer exam_corrent_rate = 50;

    public static Integer log_sleep = 100;

    public static Integer if_favor_rate = 30;

    public static Integer if_favor_cancel_rate = 10;

    public static Integer if_cart_rate = 10;

    public static Integer if_cart_add_num_rate = 10;

    public static Integer if_cart_minus_num_rate = 10;

    public static Integer if_cart_rm_rate = 10;

    public static Integer if_add_address = 15;

    public static Integer if_get_coupon = 25;

    public static Integer max_display_count = 10;

    public static Integer min_display_count = 4;

    public static Integer max_activity_count = 2;
    public static Integer max_pos_id = 5;


    public static Integer[] appraise_weight = new Integer[]{80, 10, 4, 1,5};

    public static Integer[] sourceTypeRate;

    public static Integer[] vipThreshold = new Integer[]{50, 150, 500, 1000};


    public static String[] searchKeywords;

    public static String kafka_server;
    public static String kafka_topic;


    public static Integer[] skuWeightMale;
    public static Integer[] skuWeightFemale;

    @Value("${mock.start-time-weight}")
    public void setStartTimeWeight(String start_time_weight) {
        AppConfig.start_time_weight =  ParamUtil.checkRate(start_time_weight) ;
    }

    @Value("${mock.if-init-paper}")
    public void setInitPaper(String if_init_paper) {
        AppConfig.if_init_paper = if_init_paper;
    }

    @Value("${mock.payment-type-weight}")
    public void setPaymentTypeWeight(String payment_type_weight) {
        AppConfig.payment_type_weight =  ParamUtil.checkRate(payment_type_weight) ;
    }

    @Value("${mock.user-session.count}")
    public void setUserSessionCount(Long user_session_count) {
        AppConfig.user_session_count = user_session_count;
    }

    @Value("${mock.new.user}")
    public void setNewUser(String newUser) {
        AppConfig.mock_new_user = ParamUtil.checkCount(newUser);
    }

    @Value("${mock.if-realtime}")
    public void setIfRealtime(Integer ifRealtime) {
        AppConfig.if_realtime = ifRealtime;
    }

    @Value("${mock.clear.user}")
    public void setMockClearUser(String mockClearUser) {
        AppConfig.mock_clear_user = mockClearUser;
    }

    @Value("${mock.clear.busi}")
    public void setMockClearBusi(String mockClearBusi) {
        AppConfig.mock_clear_busi = mockClearBusi;
    }

    //
//    @Value("${mock.sku-weight.male}")
//    public   void setSkuWeightMale(String skuWeightMaleStr) {
//        Integer[] skuWeightMaleArray = ParamUtil.checkRate( skuWeightMaleStr );
//        AppConfig.skuWeightMale = skuWeightMaleArray;
//    }
//
//    @Value("${mock.sku-weight.female}")
//    public   void setSkuWeightFemale(String skuWeightFemaleStr) {
//        Integer[] skuWeightFemaleArray = ParamUtil.checkRate( skuWeightFemaleStr );
//        AppConfig.skuWeightFemale = skuWeightFemaleArray;
//    }
//
//    @Value("${mock.type}")
//    public   void setMock_type(String mock_type) {
//        AppConfig.mock_type = mock_type;
//    }
//
//    @Value("${mock.url}")
//    public   void setMock_url(String mock_url) {
//        AppConfig.mock_url = mock_url;
//    }
//
//    @Value("${mock.kafka-server}")
//    public   void setKafka_server(String kafka_server) {
//        AppConfig.kafka_server = kafka_server;
//    }
//    @Value("${mock.kafka-topic}")
//    public   void setKafka_topic(String kafka_topic) {
//        AppConfig.kafka_topic = kafka_topic;
//    }
//
//
//    @Value("${mock.startup.count}")
//    public   void setMock_count(String mock_count) {
//        AppConfig.mock_count =  ParamUtil.checkCount(mock_count)  ;
//    }
//    @Value("${mock.max.mid}")
//    public   void setMax_mid(String  max_mid) {
//        AppConfig.max_mid = ParamUtil.checkCount(max_mid);
//    }
//    @Value("${mock.max.uid}")
//    public   void setMax_uid(String max_uid) {
//        AppConfig.max_uid = ParamUtil.checkCount(max_uid);
//    }
//    @Value("${mock.max.sku-id}")
//    public   void setMax_sku_id(String max_sku_id) {
//        AppConfig.max_sku_id = ParamUtil.checkCount(max_sku_id);
//    }
//    @Value("${mock.page.during-time-ms}")
//    public   void setPage_during_max_ms(String page_during_max_ms) {
//        AppConfig.page_during_max_ms = ParamUtil.checkCount(page_during_max_ms);
//    }
//     @Value("${mock.error.rate}")
//    public   void setError_rate(String error_rate) {
//        AppConfig.error_rate = ParamUtil.checkRatioNum( error_rate);
//    }
//    @Value("${mock.log.sleep}")
//    public   void setLog_sleep(String log_sleep) {
//        AppConfig.log_sleep = ParamUtil.checkCount(log_sleep);
//    }
//
//    public static void setIf_favor_rate(Integer if_favor_rate) {
//        AppConfig.if_favor_rate = if_favor_rate;
//    }
//
//    public static void setIf_favor_cancel_rate(Integer if_favor_cancel_rate) {
//        AppConfig.if_favor_cancel_rate = if_favor_cancel_rate;
//    }
//
//    public static void setIf_cart_rate(Integer if_cart_rate) {
//        AppConfig.if_cart_rate = if_cart_rate;
//    }
//
//    public static void setIf_cart_add_num_rate(Integer if_cart_add_num_rate) {
//        AppConfig.if_cart_add_num_rate = if_cart_add_num_rate;
//    }
//
//    public static void setIf_cart_minus_num_rate(Integer if_cart_minus_num_rate) {
//        AppConfig.if_cart_minus_num_rate = if_cart_minus_num_rate;
//    }
//
//    public static void setIf_cart_rm_rate(Integer if_cart_rm_rate) {
//        AppConfig.if_cart_rm_rate = if_cart_rm_rate;
//    }
//
//    public static void setIf_add_address(Integer if_add_address) {
//        AppConfig.if_add_address = if_add_address;
//    }
//
//    public static void setMax_display_count(Integer max_display_count) {
//        AppConfig.max_display_count = max_display_count;
//    }
//
//    public static void setMin_display_count(Integer min_display_count) {
//        AppConfig.min_display_count = min_display_count;
//    }
//
//    public static void setMax_activity_count(Integer max_activity_count) {
//        AppConfig.max_activity_count = max_activity_count;
//    }
//
//
////    public     void setMockDate(String  mockDate) {
////        AppConfig.date = ParamUtil.checkDate(mockDate);
////
////    }
//
    @Value("${mock.date}")
    public void setMockDate(String mockDate) {

        AppConfig.mock_date_str = mockDate;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            AppConfig.mock_date = simpleDateFormat.parse(mockDate);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new RuntimeException("日期格式不对！");
        }

    }
//
//    @Value("${mock.detail.source-type-rate}")
//    public     void setSourceType(String  sourceTypeRate) {
//        Integer[] sourceTypeRateArray = ParamUtil.checkRate( sourceTypeRate,4);
//        AppConfig.sourceTypeRate = sourceTypeRateArray;
//
//    }
//
    @Value("${mock.search.keyword}")
    public void setSearchKeywords(String keywords){
        AppConfig.searchKeywords= ParamUtil.checkArray(keywords);
    }


//
//
//    @Value("${mock.if_get_coupon_rate}")
//    public void setIf_get_coupon(String if_get_coupon_ratio){
//        AppConfig.if_get_coupon= ParamUtil.checkRatioNum( if_get_coupon_ratio);
//    }
//
//    @Value("${mock.max.coupon-id}")
//    public   void setMaxCouponId(String couponId) {
//        AppConfig.max_coupon_id = ParamUtil.checkCount(couponId);
//    }
//


}
